<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.cfml</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (ColdFusion) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7a7c7d;">&lt;!--- ColdFusion Sample File ---&gt;</span>
<span style="color:#7a7c7d;">&lt;!--- Source: https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/structure-examples.html ---&gt;</span>

<span style="font-weight:bold;">&lt;head&gt;</span>
<span style="font-weight:bold;">&lt;title&gt;</span>Add New Employees<span style="font-weight:bold;">&lt;/title&gt;</span>
<span style="font-weight:bold;">&lt;/head&gt;</span>

<span style="font-weight:bold;">&lt;body&gt;</span>
<span style="font-weight:bold;">&lt;h1&gt;</span>Add New Employees<span style="font-weight:bold;">&lt;/h1&gt;</span>
<span style="color:#7a7c7d;">&lt;!--- Action page code for the form at the bottom of this page. ---&gt;</span>

<span style="color:#7a7c7d;">&lt;!--- Establish parameters for first time through ---&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfparam</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;Form.firstname&quot;</span><span style="color:#27ae60;"> default</span>=<span style="color:#f44f4f;">&quot;&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfparam</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;Form.lastname&quot;</span><span style="color:#27ae60;"> default</span>=<span style="color:#f44f4f;">&quot;&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfparam</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;Form.email&quot;</span><span style="color:#27ae60;"> default</span>=<span style="color:#f44f4f;">&quot;&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfparam</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;Form.phone&quot;</span><span style="color:#27ae60;"> default</span>=<span style="color:#f44f4f;">&quot;&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfparam</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;Form.department&quot;</span><span style="color:#27ae60;"> default</span>=<span style="color:#f44f4f;">&quot;&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>

<span style="color:#7a7c7d;">&lt;!--- If at least the firstname form field is passed, create</span>
<span style="color:#7a7c7d;">a structure named employee and add values. ---&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfif #Form.firstname# eq </span><span style="color:#f44f4f;">&quot;&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
<span style="font-weight:bold;">&lt;p&gt;</span>Please fill out the form.<span style="font-weight:bold;">&lt;/p&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfelse&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfoutput&gt;</span>
<span style="color:#da4453;font-weight:bold;">&lt;cfscript&gt;</span>
employee<span style="font-weight:bold;">=</span><span style="color:#8e44ad;font-weight:bold;">StructNew</span><span style="font-weight:bold;">()</span>;
employee.firstname <span style="font-weight:bold;">=</span> Form.firstname;
employee.lastname <span style="font-weight:bold;">=</span> Form.lastname;
employee.email <span style="font-weight:bold;">=</span> Form.email;
employee.phone <span style="font-weight:bold;">=</span> Form.phone;
employee.department <span style="font-weight:bold;">=</span> Form.department;
<span style="color:#da4453;font-weight:bold;">&lt;/cfscript&gt;</span>

<span style="color:#7a7c7d;">&lt;!--- Display results of creating the structure. ---&gt;</span>
First name is #StructFind(employee, &quot;firstname&quot;)#<span style="font-weight:bold;">&lt;br&gt;</span>
Last name is #StructFind(employee, &quot;lastname&quot;)#<span style="font-weight:bold;">&lt;br&gt;</span>
EMail is #StructFind(employee, &quot;email&quot;)#<span style="font-weight:bold;">&lt;br&gt;</span>
Phone is #StructFind(employee, &quot;phone&quot;)#<span style="font-weight:bold;">&lt;br&gt;</span>
Department is #StructFind(employee, &quot;department&quot;)#<span style="font-weight:bold;">&lt;br&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfoutput&gt;</span>

<span style="color:#7a7c7d;">&lt;!--- Call the custom tag that adds employees. ---&gt;</span>
<span style="color:#2980b9;font-weight:bold;">&lt;cf_addemployee</span><span style="color:#27ae60;"> empinfo</span>=<span style="color:#f44f4f;">&quot;#employee#&quot;</span><span style="color:#2980b9;font-weight:bold;">&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfif&gt;</span>

<span style="color:#7a7c7d;">&lt;!--- The form for adding the new employee information ---&gt;</span>
<span style="font-weight:bold;">&lt;hr&gt;</span>
<span style="font-weight:bold;">&lt;form</span><span style="color:#27ae60;"> action</span>=<span style="color:#f44f4f;">&quot;newemployee.cfm&quot;</span><span style="color:#27ae60;"> method</span>=<span style="color:#f44f4f;">&quot;Post&quot;</span><span style="font-weight:bold;">&gt;</span>
First Name:<span style="color:#c45b00;">&amp;nbsp;</span>
<span style="font-weight:bold;">&lt;input</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;firstname&quot;</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;text&quot;</span><span style="color:#27ae60;"> hspace</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="color:#27ae60;"> maxlength</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="font-weight:bold;">&gt;&lt;br&gt;</span>
Last Name:<span style="color:#c45b00;">&amp;nbsp;</span>
<span style="font-weight:bold;">&lt;input</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;lastname&quot;</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;text&quot;</span><span style="color:#27ae60;"> hspace</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="color:#27ae60;"> maxlength</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="font-weight:bold;">&gt;&lt;br&gt;</span>
EMail:<span style="color:#c45b00;">&amp;nbsp;</span>
<span style="font-weight:bold;">&lt;input</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;email&quot;</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;text&quot;</span><span style="color:#27ae60;"> hspace</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="color:#27ae60;"> maxlength</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="font-weight:bold;">&gt;&lt;br&gt;</span>
Phone:<span style="color:#c45b00;">&amp;nbsp;</span>
<span style="font-weight:bold;">&lt;input</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;phone&quot;</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;text&quot;</span><span style="color:#27ae60;"> hspace</span>=<span style="color:#f44f4f;">&quot;20&quot;</span><span style="color:#27ae60;"> maxlength</span>=<span style="color:#f44f4f;">&quot;20&quot;</span><span style="font-weight:bold;">&gt;&lt;br&gt;</span>
Department:<span style="color:#c45b00;">&amp;nbsp;</span>
<span style="font-weight:bold;">&lt;input</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;department&quot;</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;text&quot;</span><span style="color:#27ae60;"> hspace</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="color:#27ae60;"> maxlength</span>=<span style="color:#f44f4f;">&quot;30&quot;</span><span style="font-weight:bold;">&gt;&lt;br&gt;</span>

<span style="font-weight:bold;">&lt;input</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;Submit&quot;</span><span style="color:#27ae60;"> value</span>=<span style="color:#f44f4f;">&quot;OK&quot;</span><span style="font-weight:bold;">&gt;</span>
<span style="font-weight:bold;">&lt;/form&gt;</span>
<span style="font-weight:bold;">&lt;br&gt;</span>
<span style="font-weight:bold;">&lt;/body&gt;</span>
<span style="font-weight:bold;">&lt;/html&gt;</span> 

<span style="color:#8e44ad;font-weight:bold;">&lt;cfoutput&gt;</span>
Error. No employee data was passed.<span style="font-weight:bold;">&lt;br&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfoutput&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfexit</span><span style="color:#27ae60;"> method</span>=<span style="color:#f44f4f;">&quot;ExitTag&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfelse&gt;</span>
<span style="color:#7a7c7d;">&lt;!--- Add the employee ---&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfquery</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;AddEmployee&quot;</span><span style="color:#27ae60;"> datasource</span>=<span style="color:#f44f4f;">&quot;cfdocexamples&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
INSERT INTO Employees
(FirstName, LastName, Email, Phone, Department)
VALUES (
'#attributes.empinfo.firstname#' ,
'#attributes.empinfo.lastname#' ,
'#attributes.empinfo.email#' ,
'#attributes.empinfo.phone#' ,
'#attributes.empinfo.department#' )
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfquery&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfif&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfoutput&gt;</span>
<span style="font-weight:bold;">&lt;hr&gt;</span>Employee Add Complete
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfoutput&gt;</span>

<span style="color:#7a7c7d;">&lt;!--- temperature.cfc ---&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfcomponent&gt;</span>
  <span style="color:#8e44ad;font-weight:bold;">&lt;cffunction</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;FtoC&quot;</span><span style="color:#27ae60;"> access</span>=<span style="color:#f44f4f;">&quot;public&quot;</span><span style="color:#27ae60;"> returntype</span>=<span style="color:#f44f4f;">&quot;numeric&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
    <span style="color:#8e44ad;font-weight:bold;">&lt;cfargument</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;fahrenheit&quot;</span><span style="color:#27ae60;"> required</span>=<span style="color:#f44f4f;">&quot;yes&quot;</span><span style="color:#27ae60;"> type</span>=<span style="color:#f44f4f;">&quot;numeric&quot;</span><span style="color:#8e44ad;font-weight:bold;"> /&gt;</span>
    <span style="color:#8e44ad;font-weight:bold;">&lt;cfset</span><span style="color:#27ae60;"> answer</span>=<span style="color:#8e44ad;font-weight:bold;"> (fahrenheit - 32)*100/180 /&gt;</span>
    <span style="color:#8e44ad;font-weight:bold;">&lt;cfreturn answer /&gt;</span>
  <span style="color:#8e44ad;font-weight:bold;">&lt;/cffunction&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfcomponent&gt;</span>
<span style="color:#7a7c7d;">&lt;!--- test.cfm ---&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfset</span><span style="color:#27ae60;"> fDegrees</span><span style="color:#8e44ad;font-weight:bold;"> </span>=<span style="color:#8e44ad;font-weight:bold;"> 212 /&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfinvoke</span><span style="color:#27ae60;"> component</span>=<span style="color:#f44f4f;">&quot;temperature&quot;</span><span style="color:#27ae60;"> method</span>=<span style="color:#f44f4f;">&quot;FtoC&quot;</span><span style="color:#27ae60;"> returnvariable</span>=<span style="color:#f44f4f;">&quot;result&quot;</span><span style="color:#8e44ad;font-weight:bold;">&gt;</span>
  <span style="color:#8e44ad;font-weight:bold;">&lt;cfinvokeargument</span><span style="color:#27ae60;"> name</span>=<span style="color:#f44f4f;">&quot;fahrenheit&quot;</span><span style="color:#27ae60;"> value</span>=<span style="color:#f44f4f;">&quot;#fDegrees#&quot;</span><span style="color:#8e44ad;font-weight:bold;"> /&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;/cfinvoke&gt;</span>
<span style="color:#8e44ad;font-weight:bold;">&lt;cfoutput&gt;</span>#fDegrees#<span style="color:#c45b00;">&amp;deg;</span>F = #result#<span style="color:#c45b00;">&amp;deg;</span>C<span style="color:#8e44ad;font-weight:bold;">&lt;/cfoutput&gt;</span> <span style="font-weight:bold;">&lt;br /&gt;</span>

<span style="color:#8e44ad;font-weight:bold;">&lt;cfset</span><span style="color:#27ae60;"> person</span><span style="color:#8e44ad;font-weight:bold;"> </span>=<span style="color:#8e44ad;font-weight:bold;"> CreateObject(</span><span style="color:#f44f4f;">&quot;component&quot;</span><span style="color:#8e44ad;font-weight:bold;">, </span><span style="color:#f44f4f;">&quot;Person&quot;</span><span style="color:#8e44ad;font-weight:bold;">) /&gt;</span>
</pre></body></html>
